package cn.iocoder.yudao.adminserver.modules.live.dal.mysql.projectPlan;

import cn.iocoder.yudao.adminserver.modules.live.controller.projectPlan.vo.LiveProjectPlanExportReqVO;
import cn.iocoder.yudao.adminserver.modules.live.controller.projectPlan.vo.LiveProjectPlanPageReqVO;
import cn.iocoder.yudao.adminserver.modules.live.dal.dataobject.projectPlan.LiveProjectPlanDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * 项目阶段计划 Mapper
 *
 * @author 芋艿
 */
@Mapper
public interface LiveProjectPlanMapper extends BaseMapperX<LiveProjectPlanDO> {

    default PageResult<LiveProjectPlanDO> selectPage(LiveProjectPlanPageReqVO reqVO) {
        return selectPage(reqVO, new QueryWrapperX<LiveProjectPlanDO>()
                .likeIfPresent("plan_name", reqVO.getPlanName())
                .orderByDesc("id")        );
    }

    default List<LiveProjectPlanDO> selectList(LiveProjectPlanExportReqVO reqVO) {
        return selectList(new QueryWrapperX<LiveProjectPlanDO>()
                .likeIfPresent("plan_name", reqVO.getPlanName())
                .orderByDesc("id")        );
    }

    default List<LiveProjectPlanDO> selectList(Collection<Long> projectIds) {
        if (projectIds == null) {
            projectIds = Collections.emptySet();
        }
        return selectList(new QueryWrapperX<LiveProjectPlanDO>()
                .inIfPresent("project_id", projectIds));
    }

}
